<%@ page import="sematproject.Task" %>
<!DOCTYPE html>
<html>
	<head>
		<meta name="layout" content="barraUsuario">
		<g:set var="entityName" value="${message(code: 'task.label', default: 'Task')}" />
		<title><g:message code="default.show.label" args="[entityName]" /></title>
	</head>
	<body>
	
	<g:if test="${taskInstance.state == 0}">
		<g:render template="/common/barraLateralBacklog" />
		<g:render template="/common/barraBacklogToDo" />
		<div id="pagBacklog">
		<g:form action="toDoing" method="post">
			<div id="pagToDoDoingDone">
				<table>
					<thead>
						<tr>
							<td></td>
							<g:sortableColumn property="name" title="Name" />
							<g:sortableColumn property="category" title="Category" />
							<g:sortableColumn property="description" title="Description" />
							<g:sortableColumn property="finishDate" title="Finish Date" />
							<g:sortableColumn property="startedDate" title="Started Date" />
						</tr>
					</thead>
					<tbody>
						<g:each in="${taskInstanceList}" status="i" var="taskInstance">
							<g:each in="${backlogInstance.tasks}"  var="t">
							<g:if test="${taskInstance.state == 0 && t == taskInstance}">
							<tr class="${(i % 2) == 0 ? 'even' : 'od'}">
								<td><g:checkBox name="${taskInstance.name}" value="${false}"/></td>
								<td id="tamNombre"><g:link controller="task" action="show" id="${taskInstance.id}" title="Ver detalles">${fieldValue(bean: taskInstance, field: "name")}</g:link></td>
							 	<td>${fieldValue(bean: taskInstance, field: "category")}</td>
								<td id="tamDescripcion">${fieldValue(bean: taskInstance, field: "description")}</td>
								<td><g:formatDate date="${taskInstance.finishDate}" /></td>
								<td><g:formatDate date="${taskInstance.startedDate}" /></td>
							</tr>
							</g:if>
							</g:each>
						</g:each>
					</tbody>
				</table>
			</div>			
			<g:submitButton id="botonRealizando" name="toDoing" value="Realizando" />
			<g:link controller="task" action="create" id="${backlogInstance.id}"><img id="agregarTareaIcono" title="Agregar una nueva tarea" /></g:link>
			</g:form>	
		</div>
		<g:link class='fondoTransparente' controller="backlog" action="toDo" id="${backlogInstance.id}"></g:link>
	</g:if>
	
	<g:if test="${taskInstance.state == 1}">
		<g:render template="/common/barraLateralBacklog" />
		<g:render template="/common/barraBacklogDoing" />
		<div id="pagBacklog">
		<g:form action="toDoing" method="post">
			<div id="pagToDoDoingDone">
				<table>
					<thead>
						<tr>
							<td></td>
							<g:sortableColumn property="name" title="Name" />
							<g:sortableColumn property="category" title="Category" />
							<g:sortableColumn property="description" title="Description" />
							<g:sortableColumn property="finishDate" title="Finish Date" />
							<g:sortableColumn property="startedDate" title="Started Date" />
						</tr>
					</thead>
					<tbody>
						<g:each in="${taskInstanceList}" status="i" var="taskInstance">
							<g:each in="${backlogInstance.tasks}"  var="t">
							<g:if test="${taskInstance.state == 1 && t == taskInstance}">
							<tr class="${(i % 2) == 0 ? 'even' : 'od'}">
								<td><g:checkBox name="${taskInstance.name}" value="${false}"/></td>
								<td id="tamNombre"><g:link controller="task" action="show" id="${taskInstance.id}" title="Ver detalles">${fieldValue(bean: taskInstance, field: "name")}</g:link></td>
							 	<td>${fieldValue(bean: taskInstance, field: "category")}</td>
								<td id="tamDescripcion">${fieldValue(bean: taskInstance, field: "description")}</td>
								<td><g:formatDate date="${taskInstance.finishDate}" /></td>
								<td><g:formatDate date="${taskInstance.startedDate}" /></td>
							</tr>
							</g:if>
							</g:each>
						</g:each>
					</tbody>
				</table>
			</div>			
			<g:submitButton id="botonRealizando" name="toDoing" value="Realizando" />
			<g:link controller="task" action="create" id="${backlogInstance.id}"><img id="agregarTareaIcono" title="Agregar una nueva tarea" /></g:link>
			</g:form>	
		</div>
		<g:link class='fondoTransparente' controller="backlog" action="Doing" id="${backlogInstance.id}"></g:link>
	</g:if>
	
	<g:if test="${taskInstance.state == 2}">
		<g:render template="/common/barraLateralBacklog" />
		<g:render template="/common/barraBacklogDone" />
		<div id="pagBacklog">
			<div id="pagToDoDoingDone">
				<table>
					<thead>
						<tr>
							<g:sortableColumn property="name" title="Name" />
							<g:sortableColumn property="category" title="Category" />
							<g:sortableColumn property="description" title="Description" />
							<g:sortableColumn property="finishDate" title="Finish Date" />
							<g:sortableColumn property="startedDate" title="Started Date" />
						</tr>
					</thead>
					<tbody>
						<g:each in="${taskInstanceList}" status="i" var="taskInstance">
							<g:each in="${backlogInstance.tasks}"  var="t">
							<g:if test="${taskInstance.state == 2 && t == taskInstance}">
							<tr class="${(i % 2) == 0 ? 'even' : 'od'}">
								<td id="tamNombre"><g:link controller="task" action="show" id="${taskInstance.id}" title="Ver detalles">${fieldValue(bean: taskInstance, field: "name")}</g:link></td>
							 	<td>${fieldValue(bean: taskInstance, field: "category")}</td>
								<td id="tamDescripcion">${fieldValue(bean: taskInstance, field: "description")}</td>
								<td><g:formatDate date="${taskInstance.finishDate}" /></td>
								<td><g:formatDate date="${taskInstance.startedDate}" /></td>
							</tr>
							</g:if>
							</g:each>
						</g:each>
					</tbody>
				</table>
			</div>			
		</div>
		<g:link class='fondoTransparente' controller="backlog" action="Done" id="${backlogInstance.id}"></g:link>
	</g:if>
	
	<g:form  action="delete">
		<ul id="detallesTareaPanel">
			<li><p id="letraGrandeTareaMostrar">Detalles</p></li>
			<li>Nombre: <g:field id="campoTextoD1" name="name" type="text" value="${taskInstance.name}" required="" disabled="disabled" placeholder="Nombre"/></li>
			<li>Categoria: <g:field id="campoTextoD2" name="category" type="text" maxlength="2" disabled="disabled" value="${taskInstance.category}" required="" placeholder="Categoria"/></li>
			<li><div id="letraDescripcion">Descripcion:</div><li>
			<li><g:textArea id="campoTextoD3" name="description" type="text" value="${taskInstance?.description}" disabled="disabled" placeholder="Descripción"/></li>
			<li id="fechasTarea">Fecha iniciación: <g:formatDate date="${taskInstance?.startedDate}" /><li>
			<li id="fechasTarea">Fecha finalización: <g:formatDate date="${taskInstance?.finishDate}" /><li>
			<g:if test="${taskInstance.state != 2}">
				<ul id="botonesMostrarTarea">
					<li><div id="botonEditarTarea"><g:link class="edit" action="edit" id="${taskInstance?.id}">Editar</g:link></div></li>
					<li><div id="botonEliminarTarea"><g:link class="edit" action="delete" id="${taskInstance?.id}">Eliminar</g:link></div></li>
				</ul>
			</g:if>
		</ul>
	</g:form>

	</body>
</html>

